package com.atguigu.tingshu.payment.strategy;

import com.atguigu.tingshu.common.execption.GuiguException;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class PayTypeContext {
    @Autowired
    private Map<String , PayTypeStrategy> map ;


    public PayTypeStrategy getPayTypeStrategy(String payType){
        if(!map.containsKey(payType)){
            throw new GuiguException(ResultCodeEnum.DATA_ERROR);
        }
        return map.get(payType);
    }
}
